<abp-page>
  <div #abpPageContent>
    <nz-table
      #nzTable
      [nzData]="items"
      nzSize="middle"
      [nzTotal]="total"
      [nzPageIndex]="pageIndex"
      [nzPageSize]="pageSize"
      nzShowSizeChanger
      [nzFrontPagination]="false"
      (nzQueryParams)="pageHandle($event)"
      [nzLoading]="loading"
    >
      <thead>
        <tr>
          <th>{{ '::PersonName' | abpLocalization }}</th>
          <th>{{ '::IdNumber' | abpLocalization }}</th>
          <th>{{ '::Sex' | abpLocalization }}</th>
          <th>{{ '::PersonType' | abpLocalization }}</th>
          <th>{{ '::PersonCode' | abpLocalization }}</th>
        </tr>
      </thead>
      <tbody>
        @for(item of nzTable.data; track item.id) {
        <tr>
          <td>{{ item.personName }}</td>
          <td>{{ item.idNumber }}</td>
          <td>{{ item.sex }}</td>
          <td>{{ item.personType }}</td>
          <td>{{ item.personCode }}</td>
        </tr>
        }
      </tbody>
    </nz-table>
  </div>

  <abp-page-toolbar-container class="col">
    <div nz-flex nzGap="middle">
      <nz-input-group nzSuffixIcon="search" style="width: 200px">
        <input
          nz-input
          placeholder="{{ '::Search' | abpLocalization }}"
          [(ngModel)]="filter"
          (keydown.enter)="loadData()"
        />
      </nz-input-group>
      <nz-upload [nzMultiple]="false" [nzCustomRequest]="importData" [nzShowUploadList]="false">
        <button nz-button nzType="primary" [nzLoading]="uploading">
          <span nz-icon nzType="upload"></span>
          {{ '::ImportData' | abpLocalization }}
        </button>
      </nz-upload>

      <button nz-button (click)="createHandle()">
        <span nz-icon nzType="plus"></span>
        {{ '::AddPerson' | abpLocalization }}
      </button>

      <button nz-button (click)="downloadData()" [nzLoading]="isDownloadData">
        <span nz-icon nzType="download"></span>
        {{ '::ExportData' | abpLocalization }}
      </button>

      <button nz-button (click)="downloadTemplate()" [nzLoading]="isDownloadTemplate">
        <span nz-icon nzType="export"></span>
        {{ '::ExportTemplate' | abpLocalization }}
      </button>
      <button
        nz-button
        nzDanger
        [nzLoading]="isClear"
        (nzOnConfirm)="clearHandle()"
        nz-popconfirm
        nzPopconfirmTitle="是否清空所有人员?"
      >
        <span nz-icon nzType="clear"></span>
        {{ '::ClearData' | abpLocalization }}
      </button>
    </div>
  </abp-page-toolbar-container>
</abp-page>

<app-person-edit-modal [(visible)]="isShowEditor" [person]="currentItem" (saved)="refresh()" />
